﻿#include "factory.h"
#include "runtime_engine.h"
#include "evaluate_engine.h"
#include "strategy/ssg_1_strategy.h"

#include "signal/tick_signal.h"

#include "trend/lr_trend.h"


std::shared_ptr<lt::strategy> make_strategy(lt::engine& eng, const strategy_info& stra_info)
{

	std::shared_ptr<lt::strategy> result;
	LOG_INFO("make_strategy : %d %d %s", stra_info.id, stra_info.type, stra_info.param.c_str());
	const auto& p = lt::param(stra_info.param.c_str());
	switch (stra_info.type)
	{
	case strategy_type::STG_SSG_1:
		result = std::make_shared<ssg_1_strategy>(stra_info.id, eng, stra_info.openable, stra_info.closeable, p);
		break;
	}

	return result;
}

std::shared_ptr<lt::signal> make_signal(lt::engine& eng, const signal_info& sig_info)
{

	std::shared_ptr<lt::signal> result;
	LOG_INFO("make_strategy : %d %d %s", sig_info.id, sig_info.type, sig_info.param.c_str());
	const auto& p = lt::param(sig_info.param.c_str());
	switch (sig_info.type)
	{
	case signal_type::SGN_TICK:
		result = std::make_shared<tick_signal>(sig_info.id, eng, p);
		break;
	}

	return result;
}

std::shared_ptr<lt::trend> make_trend(lt::engine& eng, const trend_info& trd_info)
{
	std::shared_ptr<lt::trend> result;
	LOG_INFO("make_trend : %d %d %s", trd_info.id, trd_info.type, trd_info.param.c_str());
	const auto& p = lt::param(trd_info.param.c_str());
	switch (trd_info.type)
	{
	case trend_type::TRD_LR:
		result = std::make_shared<lr_trend>(trd_info.id, eng, p);
		break;
	}
	return result;
}
